package com.example.test_witns;

import com.azure.android.communication.chat.ChatClient;
import com.azure.android.communication.chat.ChatClientBuilder;
import com.azure.android.communication.common.CommunicationTokenCredential;

import org.junit.Test;

import java.io.IOException;

public class App
{
    @Test
    public void app() throws IOException
    {
        System.out.println("Azure Communication Services - Chat Quickstart");

        // Your unique Azure Communication service endpoint
        String endpoint = "https://chat-service-witns.unitedstates.communication.azure.com/";

        // User access token fetched from your trusted service
        String userAccessToken = "eyJhbGciOiJSUzI1NiIsImtpZCI6IjExRkNCRjhEQzBFRTMzQUY3" +
                "QkIwQTE3OUUzNjI0RUNBNjk1ODE2NjQiLCJ4NXQiOiJFZnlfamNEdU02OTdzS0Y1NDJK" +
                "T3ltbFlGbVEiLCJ0eXAiOiJKV1QifQ.eyJza3lwZWlkIjoiYWNzOmUwZWQyYjU5LWI5Z" +
                "DMtNGM5Yi1iZmRlLWQ2NzRiZGIxZTg0Nl8wMDAwMDAyNC02NThiLTEyYTItODVmNC0zNDNh" +
                "MGQwMGU1MTkiLCJzY3AiOjE3OTIsImNzaSI6IjE3MzQxODgwMzUiLCJleHAiOjE3MzQyNzQ0" +
                "MzUsInJnbiI6ImFtZXIiLCJhY3NTY29wZSI6ImNoYXQiLCJyZXNvdXJjZUlkIjoiZTBlZDJiNT" +
                "ktYjlkMy00YzliLWJmZGUtZDY3NGJkYjFlODQ2IiwicmVzb3VyY2VMb2NhdGlvbiI6InVuaXRl" +
                "ZHN0YXRlcyIsImlhdCI6MTczNDE4ODAzNX0.gEHid3jyHtoUx6e0_VOKF9Qv3-NevW-HxxbwKo" +
                "J5AOYTRc1XnDwDtP2c06Qq0feUJVoDV-WrPVVJYrrDrdb2Znpwp4WE0xZ0UFwjcFnx_efi7mK8T" +
                "S5PtzuRVkQKnjRycGfIn8uEo5oFFR0pLagMRz1oeZdcjsw8Qo3RAFpr8wkIfMIZN9EY4W05XMts" +
                "umGnBfpV9DXVWSltyoc9-Z5PfjrVWyI2t9-T--zuPlTwk4G5Jyk4IOJJLInceheIKfejlQZVC-w" +
                "MsN5__arz0pbcMjJ7esHGQjS1SWIBY02It2zfjoY4aIeiUkfZ3iaPOBMhYgPv0p2ZBfto7tGzqnxMmQ";

        // Create a CommunicationTokenCredential with the given access token, which is only valid until the token is valid
        CommunicationTokenCredential userCredential = new CommunicationTokenCredential("eyJhbGciOiJSUzI1NiIsImtpZCI6IjExRkNCRjhEQzBFRTMzQUY3" +
                "QkIwQTE3OUUzNjI0RUNBNjk1ODE2NjQiLCJ4NXQiOiJFZnlfamNEdU02OTdzS0Y1NDJK" +
                "T3ltbFlGbVEiLCJ0eXAiOiJKV1QifQ.eyJza3lwZWlkIjoiYWNzOmUwZWQyYjU5LWI5Z" +
                "DMtNGM5Yi1iZmRlLWQ2NzRiZGIxZTg0Nl8wMDAwMDAyNC02NThiLTEyYTItODVmNC0zNDNh" +
                "MGQwMGU1MTkiLCJzY3AiOjE3OTIsImNzaSI6IjE3MzQxODgwMzUiLCJleHAiOjE3MzQyNzQ0" +
                "MzUsInJnbiI6ImFtZXIiLCJhY3NTY29wZSI6ImNoYXQiLCJyZXNvdXJjZUlkIjoiZTBlZDJiNT" +
                "ktYjlkMy00YzliLWJmZGUtZDY3NGJkYjFlODQ2IiwicmVzb3VyY2VMb2NhdGlvbiI6InVuaXRl" +
                "ZHN0YXRlcyIsImlhdCI6MTczNDE4ODAzNX0.gEHid3jyHtoUx6e0_VOKF9Qv3-NevW-HxxbwKo" +
                "J5AOYTRc1XnDwDtP2c06Qq0feUJVoDV-WrPVVJYrrDrdb2Znpwp4WE0xZ0UFwjcFnx_efi7mK8T" +
                "S5PtzuRVkQKnjRycGfIn8uEo5oFFR0pLagMRz1oeZdcjsw8Qo3RAFpr8wkIfMIZN9EY4W05XMts" +
                "umGnBfpV9DXVWSltyoc9-Z5PfjrVWyI2t9-T--zuPlTwk4G5Jyk4IOJJLInceheIKfejlQZVC-w" +
                "MsN5__arz0pbcMjJ7esHGQjS1SWIBY02It2zfjoY4aIeiUkfZ3iaPOBMhYgPv0p2ZBfto7tGzqnxMmQ");

        // Initialize the chat client
        final ChatClientBuilder builder = new ChatClientBuilder();
        builder.endpoint(endpoint)
            .credential(userCredential);
        ChatClient chatClient = builder.buildClient();
    }
}